<?php session_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?php include("db.php"); 	// Connect to the database server
dbConnect('kar_web1');   	// Use function in db.php to connect
include_once("http://02d2e0a.netsolhost.com/includes/timeout.php");?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>KAR Admin - New/Update Dog</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<?php include("http://02d2e0a.netsolhost.com/includes/head.inc");  ?>
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
</head>
<div id="bodywidth">
<?php include("http://02d2e0a.netsolhost.com/includes/header.inc");  ?>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp;</p>
<?php include("http://02d2e0a.netsolhost.com/includes/leftmenu.php");
// Check for Session, if not, display login page
if (!isset($_SESSION['name']))
{ ?>
<div id="centercontent" style="width: 475px; height: auto">
<form method="GET" action="confirmlogin.php">
<table height="300px" width="100%" border=0 >
	<td align= center valign="top">
		<table height="300px" width="100%" border=0>
			<td align="center">
				<table width="100%" border=0>
				<td align="center">
				<font size=6>KAR Volunteer and Admin Login</font>
				</td>
			</td>
		</table>

		<br>

		<table width="400px" cellpadding="5%" border="0">
		<tr>
			<td align=right><font size=3><b>User Name:</b></font></td /align>
			<td><input type="text" name="user" size="20"></td>
		</tr>
		<tr>
			<td align=right><font size=3><b>Password:</b></td /align>
			<td><input type="password" name="password" size="20"></td>
		</tr>
		</table>

		<table width="100%" border="0">
		<tr>
			<td align=center><input type="submit" value="Login">
			
		</tr>
		</table>
	</td>
</table>
</div>
<? include("http://02d2e0a.netsolhost.com/includes/footer.inc");  ?>
</div>
</body>
</html>
<?php 
}
else
{ ?>
<div id="centercontent" style="width: 475px; height: auto">
<script language="JavaScript">
<!-- ;    This JS just checks to make sure something is entered in all fields and that there are no quotation marks.
function verifyIt() {
	var form = document.forms[0];
	var field;
	var fieldName;

	if (form.name.value == "") 
		{ 
		alert("Please fill in the PET NAME before submitting the form.");
		return false;
		}
<!-- Petfinder will fail on import if not primary breed is selected
	if (form.primaryBreed.selectedIndex == 0)
		{ 
		alert("Please fill in the PRIMARY BREED before submitting the form.");
		return false;
		}

	return true
}
// end hide -->
</script>
<H2 align=center>Add/Update Foster Cat for Web Site Database</H2>
<p style="margin-left:10px;">Use <a href="http://www.mozilla.com/en-US/">Mozilla Firefox</a> for fastest and best rendering of this form.</p>
<BR CLEAR=ALL>
<?php

// Get all adopted dogs
$result = @mysql_query("SELECT * FROM dogs WHERE pet_status='a' ORDER BY pet_name");
if (!$result) {
	echo("<p>Error performing query: " . mysql_error() . "</p>");
	exit();
  } // end error checking
// Get set up to put breed names  into drop-down list for SELECT in the FORM
//  This is to present the user a drop down of possible breeds
//  Also set the path that will be used for finding the images
$breeds = @mysql_query("SELECT * FROM petfinderBreeds WHERE animalType like '%Cat%'");
$path = './images/dogs/';
// verify breed query's success
if (!$breeds) {
	echo("<p>Error performing breeds query: " . mysql_error() . "</p>");
	exit();
  }  // end if

// Check to see if a petid was passed (from intake or view pets)
if (isset($_GET['petID'])):
	$pet_edit = @mysql_query("SELECT * FROM dogs WHERE dogs.tagNum='$_GET[petID]'");
	
	if (!$pet_edit) 
	{
		echo("<p>Error performing query: " . mysql_error() . "</p>");
		 exit();	
	}
endif; 
// If a pet's ID was passed in, get it's info and load it into the page!
if (isset($_GET['petID'])):
	while ( $row = mysql_fetch_array($pet_edit) ) 
	{       // pull the record info on the pet
		$tagNum = $row["tagNum"];         // KAR tag number
		$pet_name = $row["pet_name"];	// pet name
		$description = $row["description"];	// pet description
		$adoptFee = $row["adoptFee"];	
		$hasShots=$row["hasShots"];
		$altered=$row["altered"];
		$microchipped=$row["microchipped"];
		$microchipBrand=$row["microchipBrand"];
		$microchipID=$row["microchipID"];
		$rabiesVac=$row["rabiesVac"];
		$noCats=$row["noCats"];
		$noDogs=$row["noDogs"];
		$noKids=$row["noKids"];
		$housebroken=$row["housebroken"];
		$primaryBreed = $row["primaryBreed"];
		$secondaryBreed = $row["secondaryBreed"];
		$pet_mixed = $row["pet_mixed"];
		$pet_size = $row["pet_size"];		// S, M, L, XL
		$pet_status = $row["pet_status"];	// available, adopted, etc - v, a, e, r, s
		$pet_sex = $row["pet_sex"];		// male or female - m or f
		$pet_DOB=$row["pet_DOB"];        // approx date of birth
		list($DOB_year, $DOB_month, $DOB_day) = explode("-", $pet_DOB); 
		$spec_need = $row["spec_need"];	// special needs - y or n
		// Pics of animals
		$pic1 = $row["pic1"];
		$pic2 = $row["pic2"];
		$pic3 = $row["pic3"];
		$thumb = $row["thumb"];
		// New Field for Foster Name
		$foster_name = $row["foster_name"];
		$spec_descrip = $row["spec_descrip"];  // special needs description
		}	// end while
endif;

$option_block2 = "<OPTION value=\"NULL\" SELECTED>-- Select a Breed --</OPTION>";
$option_block3 = "<OPTION value=\"NULL\" SELECTED>-- No Secondary Breed--</OPTION>";
while ($row = mysql_fetch_array($breeds)) {
	$breedID = $row["breedID"];
	$breedName  = $row["breedName"];
// ************** Need to change next line once we know what this is
	if ($breedID != $primaryBreed) {	// primaryBreed came from the record to edit
		$option_block2 .= "<OPTION value=\"$breedID\">$breedName</OPTION>";  }
	else  {  // When we find the one that is the current breed, mark as selected
		$option_block2 .= "<OPTION value=\"$breedID\" SELECTED>$breedName</OPTION>";  }
	if ($breedID != $secondaryBreed) {	// secondaryBreed came from the record to edit
		$option_block3 .= "<OPTION value=\"$breedID\">$breedName</OPTION>";  }
	else  {  // When we find the one that is the current breed, mark as selected
		$option_block3 .= "<OPTION value=\"$breedID\" SELECTED>$breedName</OPTION>";  }
}  // end while
// echo "we're ready to start form<BR>";

?>

<!--  *************  FORM STARTS HERE  ********************  -->
<form enctype="multipart/form-data"  action="postit1TEST.php<?php if (isset($update)) echo("?update=1");?>" method="post" onSubmit="return verifyIt()">

<?php if (isset($update)) echo("<input type=hidden name=\"pet_id\" value=\"".$temp_id."\">"); 

echo("<input type=hidden name=\"pet_type\" value=\"".$type."\">");  
?>
<div>   
<fieldset> <legend>Pet Details</legend>
<p><label for="name">Pet Name: </label><input type="text" id="name"  name="name" value="<?php echo $pet_name;?>"><br /><br /></p>

<p><label for="tagNum">KAR Tag Number: </label><input type="text" id="tagNum" name="tagNum" value="<?php echo $tagNum;?>">
<br /><br /></p>

<p><label for="foster_mom">Foster Parent: </label><input type="text" id="foster_name" name="foster_name" value="<?php echo $foster_name;?>">
<br /><br /></p>

<p><label for="status">Pet Status: </label><select id="status" NAME="status" class="bodytext">
<option VALUE="v" <?php if ($pet_status =='v') echo("selected=\"selected\"");?>>Available</option>
<option VALUE="a" <?php if ($pet_status =='a') echo("selected=\"selected\"");?>>Adopted</option>
<option VALUE="e" <?php if ($pet_status =='e') echo("selected=\"selected\"");?>>Euthanized</option>
<option VALUE="r" <?php if ($pet_status =='r') echo("selected=\"selected\"");?>>Other</option>
<option VALUE="s" <?php if ($pet_status =='s') echo("selected=\"selected\"");?>>Sidelined</option>
<option VALUE="i" <?php if ($pet_status =='i') echo("selected=\"selected\"");?>>Intake</option>
</select><br /><br /></p>

<p><label for="primaryBreed">Primary Breed: </label>
<SELECT class="bodytext" id="primaryBreed" name="primaryBreed">
<?php echo "$option_block2"; ?>
</SELECT>
<br /><br /></p>
<p><label for="secondaryBreed">Secondary Breed: </label>
<SELECT class="bodytext" id="secondaryBreed" name="secondaryBreed">
<?php echo "$option_block3"; ?>
</SELECT><BR><br /></p>
<p><label for="DOB_month">Approximate Birth Date: </label>
<select class="bodytext" id="DOB_month" NAME="DOB_month">
<option VALUE="01" <?php if ($DOB_month=='01') echo("selected=\"selected\"");?>>Jan</option>
<option VALUE="02" <?php if ($DOB_month=='02') echo("selected=\"selected\"");?>>Feb</option>
<option VALUE="03" <?php if ($DOB_month=='03') echo("selected=\"selected\"");?>>Mar</option>
<option VALUE="04" <?php if ($DOB_month=='04') echo("selected=\"selected\"");?>>Apr</option>
<option VALUE="05" <?php if ($DOB_month=='05') echo("selected=\"selected\"");?>>May</option>
<option VALUE="06" <?php if ($DOB_month=='06') echo("selected=\"selected\"");?>>Jun</option>
<option VALUE="07" <?php if ($DOB_month=='07') echo("selected=\"selected\"");?>>Jul</option>
<option VALUE="08" <?php if ($DOB_month=='08') echo("selected=\"selected\"");?>>Aug</option>
<option VALUE="09" <?php if ($DOB_month=='09') echo("selected=\"selected\"");?>>Sep</option>
<option VALUE="10" <?php if ($DOB_month=='10') echo("selected=\"selected\"");?>>Oct</option>
<option VALUE="11" <?php if ($DOB_month=='11') echo("selected=\"selected\"");?>>Nov</option>
<option VALUE="12" <?php if ($DOB_month=='12') echo("selected=\"selected\"");?>>Dec</option>
</select>&nbsp;&nbsp;
<select class="bodytext" NAME="DOB_day">
<option VALUE="01" <?php if ($DOB_day=='01') echo("selected=\"selected\"");?>>1</option>
<option VALUE="02" <?php if ($DOB_day=='02') echo("selected=\"selected\"");?>>2</option>
<option VALUE="03" <?php if ($DOB_day=='03') echo("selected=\"selected\"");?>>3</option>
<option VALUE="04" <?php if ($DOB_day=='04') echo("selected=\"selected\"");?>>4</option>
<option VALUE="05" <?php if ($DOB_day=='05') echo("selected=\"selected\"");?>>5</option>
<option VALUE="06" <?php if ($DOB_day=='06') echo("selected=\"selected\"");?>>6</option>
<option VALUE="07" <?php if ($DOB_day=='07') echo("selected=\"selected\"");?>>7</option>
<option VALUE="08" <?php if ($DOB_day=='08') echo("selected=\"selected\"");?>>8</option>
<option VALUE="09" <?php if ($DOB_day=='09') echo("selected=\"selected\"");?>>9</option>
<option VALUE="10" <?php if ($DOB_day=='10') echo("selected=\"selected\"");?>>10</option>
<option VALUE="11" <?php if ($DOB_day=='11') echo("selected=\"selected\"");?>>11</option>
<option VALUE="12" <?php if ($DOB_day=='12') echo("selected=\"selected\"");?>>12</option>
<option VALUE="13" <?php if ($DOB_day=='13') echo("selected=\"selected\"");?>>13</option>
<option VALUE="14" <?php if ($DOB_day=='14') echo("selected=\"selected\"");?>>14</option>
<option VALUE="15" <?php if ($DOB_day=='15') echo("selected=\"selected\"");?>>15</option>
<option VALUE="16" <?php if ($DOB_day=='16') echo("selected=\"selected\"");?>>16</option>
<option VALUE="17" <?php if ($DOB_day=='17') echo("selected=\"selected\"");?>>17</option>
<option VALUE="18" <?php if ($DOB_day=='18') echo("selected=\"selected\"");?>>18</option>
<option VALUE="19" <?php if ($DOB_day=='19') echo("selected=\"selected\"");?>>19</option>
<option VALUE="20" <?php if ($DOB_day=='20') echo("selected=\"selected\"");?>>20</option>
<option VALUE="21" <?php if ($DOB_day=='21') echo("selected=\"selected\"");?>>21</option>
<option VALUE="22" <?php if ($DOB_day=='22') echo("selected=\"selected\"");?>>22</option>
<option VALUE="23" <?php if ($DOB_day=='23') echo("selected=\"selected\"");?>>23</option>
<option VALUE="24" <?php if ($DOB_day=='24') echo("selected=\"selected\"");?>>24</option>
<option VALUE="25" <?php if ($DOB_day=='25') echo("selected=\"selected\"");?>>25</option>
<option VALUE="26" <?php if ($DOB_day=='26') echo("selected=\"selected\"");?>>26</option>
<option VALUE="27" <?php if ($DOB_day=='27') echo("selected=\"selected\"");?>>27</option>
<option VALUE="28" <?php if ($DOB_day=='28') echo("selected=\"selected\"");?>>28</option>
<option VALUE="29" <?php if ($DOB_day=='29') echo("selected=\"selected\"");?>>29</option>
<option VALUE="30" <?php if ($DOB_day=='30') echo("selected=\"selected\"");?>>30</option>
<option VALUE="31" <?php if ($DOB_day=='31') echo("selected=\"selected\"");?>>31</option>
</select>&nbsp;&nbsp;
<select class="bodytext" NAME="DOB_year">
  <option value="2010">2010</option>
<option value="2009" <?php if ($DOB_year=='2009') echo("selected=\"selected\"");?>>2009</option>
<option value="2008" <?php if ($DOB_year=='2008') echo("selected=\"selected\"");?>>2008</option>
<option value="2007" <?php if ($DOB_year=='2007') echo("selected=\"selected\"");?>>2007</option>
<option value="2006" <?php if ($DOB_year=='2006') echo("selected=\"selected\"");?>>2006</option>
<option value="2005" <?php if ($DOB_year=='2005') echo("selected=\"selected\"");?>>2005</option>
<option value="2004" <?php if ($DOB_year=='2004') echo("selected=\"selected\"");?>>2004</option>
<option value="2003" <?php if ($DOB_year=='2003') echo("selected=\"selected\"");?>>2003</option>
<option value="2002" <?php if ($DOB_year=='2002') echo("selected=\"selected\"");?>>2002</option>
<option value="2001" <?php if ($DOB_year=='2001') echo("selected=\"selected\"");?>>2001</option>
<option value="2000" <?php if ($DOB_year=='2000') echo("selected=\"selected\"");?>>2000</option>
<option value="1999" <?php if ($DOB_year=='1999') echo("selected=\"selected\"");?>>1999</option>
<option value="1998" <?php if ($DOB_year=='1998') echo("selected=\"selected\"");?>>1998</option>
<option value="1997" <?php if ($DOB_year=='1997') echo("selected=\"selected\"");?>>1997</option>
<option value="1996" <?php if ($DOB_year=='1996') echo("selected=\"selected\"");?>>1996</option>
<option value="1995" <?php if ($DOB_year=='1995') echo("selected=\"selected\"");?>>1995</option>
<option value="1994" <?php if ($DOB_year=='1994') echo("selected=\"selected\"");?>>1994</option>
<option value="1993" <?php if ($DOB_year=='1993') echo("selected=\"selected\"");?>>1993</option>
<option value="1992" <?php if ($DOB_year=='1992') echo("selected=\"selected\"");?>>1992</option>
<option value="1991" <?php if ($DOB_year=='1991') echo("selected=\"selected\"");?>>1991</option>
<option value="1990" <?php if ($DOB_year=='1990') echo("selected=\"selected\"");?>>1990</option>
<option value="1989" <?php if ($DOB_year=='1989') echo("selected=\"selected\"");?>>1989</option>
<option value="1988" <?php if ($DOB_year=='1988') echo("selected=\"selected\"");?>>1988</option>
<option value="1987" <?php if ($DOB_year=='1987') echo("selected=\"selected\"");?>>1987</option>
</select><br /><BR></p>

<p><label for="pet_size">Size (when grown): </label>
<select id="pet_size" name="pet_size" class="bodytext">           
<option value='S' selected=\"selected\">Small</option>
<option value='M' <?php if ($pet_size =='M') echo("selected=\"selected\"");?>>Medium</option>                 
<option value='L' <?php if ($pet_size =='L') echo("selected=\"selected\"");?>>Large</option>                 
<option value='XL' <?php if ($pet_size =='XL') echo("selected=\"selected\"");?>>X-Large</option>                 
</select><BR/><br /></p>

<p><label for="pet_sex">Sex: </label><select class="bodytext"  id="pet_sex" NAME="pet_sex">
<option VALUE="m" <?php if ($pet_sex =='m') echo("selected=\"selected\"");?>>Male</option>
<option VALUE="f"  <?php if ($pet_sex =='f') echo("selected=\"selected\"");?>>Female</option>
</select><BR><br /></p>

<p><label for="adoptFee">Adoption Fee<BR><span style="font-size:85%;">Enter a Number Only (such as 150 )</span></label><input type="text" id="adoptFee"  name="adoptFee" value="<?php echo $adoptFee;?>">
<br /><BR></p>

<!-- ************************************************************************************************ -->
<!-- ************************************************************************************************ -->

<fieldset style="width:40em;">
<legend>Microchip</legend>
<div style="width:40em;float:left;"><BR>
<p><label for="microchipped">Pet has been Microchipped</label>
	<input type="checkbox" class="boxes" <?php if ($microchipped =='1') echo("CHECKED");?> id="microchipped" name="microchipped" value="1" ><br /><BR></p>

<p>  <label for="microchipBrand">Microchip Brand</label><input type="text" id="microchipBrand"  name="microchipBrand" size=30 value="<?php echo $microchipBrand;?>">
<br /><BR></p>

<p>  <label for="microchipID">Microchip ID</label><input type="text" id="microchipID"  size=30 name="microchipID" value="<?php echo $microchipID;?>">
<br /><BR></p>

</fieldset>

<fieldset style="width:40em;">
<legend>Check All That Apply</legend>
<div style="width:20em;float:left;">

              <p class="chkbox"><label for="pet_mixed">Mixed Breed </label>
	<input type="checkbox"  class="boxes" <?php if ($pet_mixed =='1') echo("CHECKED");?> id="pet_mixed" name="pet_mixed" value="1" />
              <br /></p>
              
	<p class="chkbox"><label for="spec_need">Special Needs</label>
	<input type="checkbox" class="boxes" <?php if ($spec_need =='1') echo("CHECKED");?> id="spec_need" name="spec_need" value="1" >
              <br /></p>
 
              <p class="chkbox"><label for="altered">Spayed/Neutered </label>
	<input type="checkbox" class="boxes" <?php if ($altered =='1') echo("CHECKED");?> id="altered" name="altered" value="1" >
              <br /></p>
 
                 <p class="chkbox"><label for="hasShots">Up to date with shots</label>
	<input type="checkbox" class="boxes" <?php if ($hasShots =='1') echo("CHECKED");?> id="hasShots" name="hasShots" value="1" >
              <br /></p>

               <p class="chkbox"><label for="housebroken">Housebroken</label>
	<input type="checkbox" class="boxes" <?php if ($housebroken =='1') echo("CHECKED");?> id="housebroken" name="housebroken" value="1"  >
              <br /></p>
</div>
<div style="float:right;">
           <p><label for="noDogs">Home without dogs</label>
	<input type="checkbox" class="boxes" <?php if ($noDogs =='1') echo("CHECKED");?> id="noDogs" name="noDogs" value="1" >
              <br /></p>

              <p><label for="noCats">Home without cats</label>
	<input type="checkbox" class="boxes" <?php if ($noCats =='1') echo("CHECKED");?> id="noCats" name="noCats" value="1" >
              <br /></p>

              <p><label for="noKids">Home without kids (&lt; 5yrs)</label>
	<input type="checkbox" class="boxes" <?php if ($noKids =='1') echo("CHECKED");?> id="noKids" name="noKids" value="1" >
              <br /> <br /></p>
	
              <p class="chkbox"><label for="rabiesVac">Vaccinated for Rabies</label>
	<input type="checkbox" class="boxes" <?php if ($rabiesVac =='1') echo("CHECKED");?> id="rabiesVac" name="rabiesVac" value="1" >
              <br /></p>

</div>

</fieldset>

<fieldset >
<legend>Pet Description</legend>
<div style="font:arial 11;">
<b>On all but the first paragraph</b>, start paragraphs with &lt;P&gt; (this is the preferred method over using &lt;BR&gt; to achieve blank lines)<BR>
</div>

<textarea id="descrip" name="descrip" rows="10" cols="80" ><? echo $description;?></textarea><BR><BR>

</fieldset >


<fieldset style="background:#ffffcc" >
<legend>Images</legend>

<p align=right style="background=#ddd;">Photos 1-3 can be a max of 50K each with dimensions no larger than 500x500 pixels</p><BR>

	<p style="border:1px solid;padding:2px;margin:2px 0px 2px 15px;"><B>Check this box if NO PHOTO is available.  <U>UNCHECK</U> it when you have photos</b>
	<input type="checkbox" class="boxes" <?php if ($noPhotos =='1') echo("CHECKED");?> id="noPhotos" name="noPhotos" value="1" />
              </p><BR><BR>
</fieldset>

<BR><BR>
<CENTER>
<input type="submit" name="submitpet" value="SUBMIT PET" />
</CENTER>

</form>
</div> <!-- To close div before first fieldset -->
 </div>
</body>
</html>
<?php } ?>